﻿
function AvailablePermission() {
    var self = this;
    self.saveToPermission = function () {
        var ids = new Array();
        $("#dataList").find("tbody tr").each(function (index, item) {
            var checkbox = $(item).find("td:first-child input[type=checkbox]")[0];

            if (checkbox.checked)
                ids.push(checkbox.value);
        });
        if (ids.length === 0) {
            window.app.message("请选择。");
            return;
        }

        $.post("/AvailablePermission/SaveToPermission", { "ids": ids },
            function (data) {
                if (data.errors.length > 0) {
                    window.app.message(data.errors);
                    return;
                } else {
                    window.app.message("保存成功。");
                }
            });

    }
}